home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / varia / rpc.lha / dynload / sub.cxx < prev   
C/C++ Source or Header  |  1993-08-08  |  1KB  |  50 lines

  1. // Copyright (C) 1990 by Glenn Gribble; all rights are reserved.
  2. // This program may be used for any purposes including inclusion in
  3. // for profit programs.  If the source is copied, the copyright notice
  4. // must be included.  Please send bug fixes/reports to glenn@synaptics.com
  5. // This program is distributed without any warranty.
  6.  
  7. // A simple subroutine file
  8.  
  9. #include "loaderTest.h"
  10. #include <stdio.h>
  11.  
  12. // A hack to declare a procedure that gets called when this file
  13. // gets loaded
  14. #define MAGICINITPROCEDURENAMED(I)            \
  15. class I { inline void II(); public: I() {II();} };    \
  16. static I needed;                    \
  17. inline void I::II()
  18. #define MAGICINITPROCEDURE() MAGICINITPROCEDURENAMED(init)
  19.  
  20. #if 0
  21. int goop;
  22.  
  23. int   i = (int)   &procA;
  24. int   ig= (int)   &goop;
  25.  
  26. int   ip = ((int)   &procA) + 83;
  27. int   igp= ((int)   &goop)  + 83;
  28.  
  29. void yourProc() { }
  30.  
  31. void myProc()
  32. {
  33.   yourProc();
  34. }
  35. #endif
  36.  
  37. void subProc(const char *msg)
  38. {
  39.   //myProc();
  40.   fprintf(stderr,"subProc: %s\n", msg);
  41. }
  42.  
  43. MAGICINITPROCEDURE()
  44. {
  45.   (*procA)("start-magicinit");
  46.   fprintf(stderr,"subMagic\n");
  47.   procA = subProc;
  48.   (*procA)("end-magicinit");
  49. }
  50.